<!-- 共用编辑/属性 开始 -->
{foreach name="attlist" id="attRs"}
    <div class="row form-group">
        {switch attRs['fieldtype']}
            {case radio}
                <div class="col-md-3 col-form-label text-right">{$attRs.title}</div>
                <div class="col-md-4">
                    <input type="hidden" name="attname[]" value="{$attRs.id}@{$attRs.title}@radio">
                    <select name="radio{$key}" class="form-control">
                        {foreach name="attRs['attvalue']" id="aRs"}
                            <?php $attFlag = array($attRs['id'],'"'.str_replace('*','',$aRs).'"'); ?>
                            <option value="{:str_replace('*','',$aRs)}" {if (empty($rs) and stripos($aRs,'*') !== false) or (in_array($attFlag,$rs['attvalue']))}selected="selected"{/if}>
                                {:str_replace('*','',$aRs)}
                            </option>
                        {/foreach}
                    </select>
                </div>
            {/case}
            {case checkbox}
                <div class="col-md-3 text-right">{$attRs.title}</div>
                <div class="col-md-4">
                    <input type="hidden" name="attname[]" value="{$attRs.id}@{$attRs.title}@checkbox">
                    {foreach $attRs['attvalue'] as $jj => $aRs}
                        <?php
                            $checked = 0; $aRsVal = str_replace('*','',$aRs);
                            foreach($rs['attvalue'] as $v){
                                if($v[0] == $attRs['id']){
                                    if(in_array($aRsVal,json_decode($v[1]))){
                                        $checked = 1;
                                        break;
                                    }
                                }
                            }
                        ?>
                        <label class="form-check form-check-inline">
                            <input type="checkbox" name="checkbox{$key}[]" value="{:str_replace('*','',$aRs)}" {if (empty($rs) and stripos($aRs,'*') !== false) or ($checked == 1)}checked="checked"{/if} class="form-check-input">{:str_replace('*','',$aRs)}
                        </label>
                    {/foreach}
                </div>
            {/case}
            {case textarea}
                <div class="col-md-3 text-right">{$attRs.title}</div>
                <div class="col-md-4">
                    <input type="hidden" name="attname[]" value="{$attRs.id}@{$attRs.title}@textarea">
                    <?php
                        $textarea = '';
                        foreach($rs['attvalue'] as $v){
                            if($v[0] == $attRs['id']){
                                $textarea = json_decode($v[1]);
                            }
                        }
                    ?>
                    <textarea name="textarea{$key}" class="form-control" placeholder="{$attRs.attvalue|raw}">{$textarea|raw}</textarea>
                </div>
            {/case}
            {default /}
                <div class="col-md-3 col-form-label text-right">{$attRs.title}</div>
                <div class="col-md-4">
                    <input type="hidden" name="attname[]" value="{$attRs.id}@{$attRs.title}@text">
                    <?php
                        $text = '';
                        foreach($rs['attvalue'] as $v){
                            if($v[0] == $attRs['id']){
                                $text = json_decode($v[1]);
                            }
                        }
                    ?>
                    <input type="text" name="text{$key}" value="{$text|raw}" placeholder="{$attRs.attvalue|raw}" class="form-control">
                </div>
        {/switch}
    </div>    
{/foreach}
<!-- 共用编辑/属性 结束 -->